Hi, i have a problem, in some formal modules dosen't exist a attribute. And now i search a method to check if a module attribute exists.
Module m
string test = "Test"
string test2 = "Test2"
...
if ( type(it)=="Formal" )
{
Folder fold = getParentFolder(it)
m = read(fullName(it), false)
print m.test"\n"
print m.test2"\n"
}
At my second module he says "unknown Module attribute (Test2)"
I search something like if(!exists(m.test2)) { // Do something } meinhana - Wed Aug 05 07:29:48 EDT 2015 |
Re: How to check if module attribute exists? Try AttrDef ad if (!null (ad = find(m, test2))) { |
Re: How to check if module attribute exists? Thank you, but he go in when the attribute is empty... not when the attribute not exists |
Re: How to check if module attribute exists? Hi Meinhana,
You can also use the following command in your if statement: if(!null attribute "insert the name of the attribute here"){ You won't have to declare an extra variable and thus will save memory. Hope that helps |
Re: How to check if module attribute exists?
-Louie |
Re: How to check if module attribute exists? llandale - Wed Aug 05 18:37:32 EDT 2015
-Louie Thank you, exactly what i need :) |
Re: How to check if module attribute exists? Rolan - Wed Aug 05 08:18:19 EDT 2015 Try AttrDef ad if (!null (ad = find(m, test2))) { You can put an assignment statement inside an "if" condition? Golly where have I been. I don't think you should want to however; makes the code confusing. -Louie |